{include file="./layout/header.html" /}

<body>
<div class="x-body" >
    <form class="layui-form" id="intr">

        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input   type="hidden" id="sid" name="sid"s required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="" value='{$sid}'>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="type" class="layui-form-label">
                <span class="x-red">*</span>邮件类型
            </label>
            <div class="layui-input-inline">
                <select name="type" lay-verify="">
                    <option value="">请选择邮件模板</option>
                    <option value="MEMBER_REGISTER">注册邮件模板</option>
                </select>
            </div><span style="line-height: 37px">默认为注册邮件模板</span>
        </div>

        {foreach $lang.hy as $vo}
        <div class="layui-form-item">
            <label for="['{$vo.lan}']['title']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.title}
            </label>
            <div class="layui-input-inline">
                <input   type="text" id="['{$vo.lan}']['title']" name="translations[{$vo.lan}][title]" required="" lay-verify="required"
                         autocomplete="off" class="layui-input" placeholder="">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="['{$vo.lan}']['content']" class="layui-form-label">
                <span class="x-red">*</span>{$vo.content}
            </label>
            <div class="layui-input-block">
                <!--<div><span>{{UserTitle}}</span><span>{{UserFirstName}}</span><span>{UserMiddleName}}</span><span>{{UserLastName}}</span><span>{{UserNickName}}</span></div>-->
                <!--<div class="layui-btn-group">-->
                    <!--快捷选项：-->
                    <!--<span>用户头衔：{{UserTitle}}&nbsp;&nbsp;||&nbsp;&nbsp;</span>-->
                    <!--<span>用户姓名：{{UserFirstName}}-{UserMiddleName}}-{{UserLastName}}&nbsp;&nbsp;||&nbsp;&nbsp;</span>-->
                    <!--<span>用户昵称：{{UserNickName}}</span>-->
                <!--</div><br><br>-->
                <textarea style="padding:0px" placeholder="请输入内容" id="['{$vo.lan}']['content']" name="translations[{$vo.lan}][content]" class="layui-textarea">Welcome
                </textarea>
            </div>
        </div>
        {if condition="$vo.lan eq 'en'"}
        <span class="layui-btn " style="margin-left: 110px;line-height: 21px;height: 21px;" onclick="setContent1(true)">用户头衔</span>
        <span class="layui-btn" style="margin-left: 10px;line-height: 21px;height: 21px;" onclick="setContent10(true)">用户姓名</span>
        <span  class="layui-btn " style="margin-left: 10px;line-height: 21px;height: 21px;" onclick="setContent11(true)">用户昵称</span><br><br><br>
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor("['en']['content']");
            function setContent1(isAppendTo) {
                var arr = [];
                UE.getEditor("['en']['content']").setContent('{{UserTitle}}', isAppendTo);
            }
            function setContent10(isAppendTo) {
                var arr = [];
                UE.getEditor("['en']['content']").setContent('{{UserFirstName}}-{UserMiddleName}}-{{UserLastName}}', isAppendTo);
            }
            function setContent11(isAppendTo) {
                var arr = [];
                UE.getEditor("['en']['content']").setContent('{{UserNickName}}', isAppendTo);
            }
        </script>

        {else/}
        <span class="layui-btn" style="margin-left: 110px;line-height: 21px;height: 21px;" onclick="setContent2(true)">用户头衔</span>
        <span class="layui-btn" style="margin-left: 10px;line-height: 21px;height: 21px;" onclick="setContent20(true)">用户姓名</span>
        <span class="layui-btn" style="margin-left: 10px;line-height: 21px;height: 21px;" onclick="setContent21(true)">用户昵称</span><br><br>
        <script type="text/javascript">
            var ue = UE.getEditor("['zh-CN']['content']");

            function setContent2(isAppendTo) {
                var arr = [];
                UE.getEditor("['zh-CN']['content']").setContent('{{UserTitle}}', isAppendTo);
            }
            function setContent20(isAppendTo) {
                var arr = [];
                UE.getEditor("['zh-CN']['content']").setContent('{{UserFirstName}}-{UserMiddleName}}-{{UserLastName}}', isAppendTo);
            }
            function setContent21(isAppendTo) {
                var arr = [];
                UE.getEditor("['zh-CN']['content']").setContent('{{UserNickName}}', isAppendTo);
            }
        </script>
        {/if}
        {/foreach}

        <div class="layui-form-item">
            <label  class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                增加
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
            // var str = new Array(); //定义一数组
            // str = uri$('#intr').serialize();
            var formData = $("#intr").serialize();
            console.log(formData);

            //发异步，把数据提交给php
            $.ajax({
                dataType : 'json',
                type : 'POST',
                url : '{:url("Conferemail/add")}',
                async: false,
                data : formData,
                success : function(msg){
                    layer.alert(msg.msg, {icon: 6},function () {
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status + "," + textStatus);
                }
            });

            return false;
        });


    });


</script>
{include file="./layout/footer.html" /}